function createProjectTask(projectNameReadonly,detialProjectId,detialProject,mode){
	
	var projectdetailStore=CRM.commons.createComboStore('projectdetailStore','projectTask/deatilsDropDownList','projects');
	
	var memberDetailsStore;
		if(mode=='local')
			memberDetailsStore=CRM.commons.createComboStore('memberDetailsStore','projectTask/deatilsDropDownList');
		if(mode=='remote')
			memberDetailsStore=CRM.commons.createComboStore('memberDetailsStore','projectTask/deatilsDropDownList?projectId='+detialProjectId+'&operation=members');
	
	var priorityDetailStore=CRM.commons.createComboStore('priorityDetailStore','projectTask/deatilsDropDownList','priority');
	var statusDetailStore=CRM.commons.createComboStore('statusDetailStore','projectTask/deatilsDropDownList','status');
	var resolutionDetailStore=CRM.commons.createComboStore('resolutionDetailStore','projectTask/deatilsDropDownList','resolution');
	var unitsDetailStore=CRM.commons.createComboStore('unitsDetailStore','projectTask/deatilsDropDownList','units');
	
	
		var taskDescription={
				xtype:'panel',
				id:'taskDescription',
				layout:'form',
				
				items:[
				       
				      {xtype:'hidden',id:'id'} 
				       ,
				       {   xtype    	: 'combo',
                           id       	: 'detialProject',
                           fieldLabel	:'Projects',
                           store		: projectdetailStore,
                           displayField : 'name',
                           valueField  	: 'id',
                           triggerAction: 'all',
                           width		: 160,
                           editable		: false,
                           value		: detialProject,
                           readOnly		: projectNameReadonly,
                           listeners : {select : function(combo,record,index){
				    	   
				    	   bindValue('detialProject','detialProjectId');
				    	   
				    	   memberDetailsStore.reload({
					       			params:{
					       			operation:'members',
					       			projectId:record.get('id')
					       			
					       		}
					       		});
				       }}
      				   }
				       ,
				       {xtype:'hidden',id:'detialProjectId',value:detialProjectId}
				       ,
      				    { xtype:'textfield',fieldLabel:'TaskName',width:350,id:'detialTaskName'}
				       ,
				       	{xtype:'textarea',fieldLabel:'Task Details',height:70,width:350,id:'detialTaskDetail'}
				       ,
				       {
				    	   xtype:'compositefield',
				    	   items:[
				    	          {
				    	        	  xtype    	: 'combo',
			                           id       	: 'detialPriority',
			                           fieldLabel	:'Priority',
			                           store		: priorityDetailStore,
			                           displayField : 'name',
			                           valueField  	: 'id',
			                           triggerAction: 'all',
			                           width		: 160,
			                           editable		: false,
			                           listeners:{select:function(){
				    	        	  bindValue('detialPriority','detialPriorityId');
				    	          }
				    	          } 
				    	          }
				    	          ,
				    	          {xtype:'hidden',id:'detialPriorityId',value:'0'}
				    	          ,
				    	          {
				    	        	  xtype:'checkbox',
				    	        	  boxLabel:'MileStone',
				    	        	  id:'detialMileStone'
				    	          }
				    	          ]
				       },
				      /* {
				    	   	xtype	  : 'textfield',
							inputType : 'file',
							id		  : 'file',
							fieldLabel: 'Upload File'
				       },*/
				       {
				    	   xtype:'label',
				    	  
				    	   html:'<span style="font-size:14px;color:blue">Estimate Time</span><hr/>'
				    	   
				       },
				       
				       { xtype:'compositefield',
				    	   items:[
				    	          {
				    	        	  xtype:'textfield',
				    	        	  fieldLabel:'Duration',
				    	        	  id:'detialEstmDuration',
				    	        	  width : 40
				    	        	  
				    	          },
				    	          {
				    	        	xtype:'combo',
				    	        	id:'detailDurationComdo',
				    	        	width:150,
				    	        	emptyText	 : 'SELECT',
				    	        	store		: unitsDetailStore,
			                        displayField : 'name',
			                        valueField  	: 'id',
			                        triggerAction: 'all',
			                        width		: 75,
			                        editable		: false
				    	          }
				    	          ]
				    	   },
				    	   {
				    		   xtype:'compositefield',
				    		   width:580,
				    		   items:[
				    		           {
				    		        	   xtype:'datefield',
				    		        	   fieldLabel:'Start Date',
				    		        	   id:'detialEstmStarDate',
				    		        	   width: 120,
				    		        	   format   : 'Y-m-d',
				    		        	   listeners:{
							    	        	  blur:function(sdt){
							    	        	  var dunit=projectTaskForm.getForm().findField('detailDurationComdo').getValue();
							    	        	  var dvalue=projectTaskForm.getForm().findField('detialEstmDuration').getValue();
							    	        	  var nextdt=new Date(this.value);
							    	        	  if(dunit!=undefined && dvalue!=undefined)
							    	        	  {
							    	        		  
							    	        		  var num=new Number(dvalue);
							    	        		 
							    	        		  if(dunit==0)nextdt=nextdt.add(Date.HOUR,num);
							    	        		  if(dunit==1)nextdt=nextdt.add(Date.DAY,num); 
							    	        		  if(dunit==2)nextdt=nextdt.add(Date.MONTH,num);
							    	        		 
							    	        		  projectTaskForm.getForm().findField('detialEstmEndDate').setValue(nextdt);
							    	        		 
							    	        	  }
							    	          }
							    	          }
				    		        	},
				    		           {xtype:'displayfield',html:'End Date:',width: 90},
				    		           {xtype:'datefield',format   : 'Y-m-d',id:'detialEstmEndDate',readOnly:true}
				    		           
				    		           
				    		          ]
				    	   }
				       ,
				       {
				    	   xtype:'label',
				    	  
				    	   html:'<span style="font-size:14px;color:blue">Actual Time</span><hr/>'
				    	   
				       },
					       {
				    		   xtype    	: 'combo',
	                           id       	: 'detailAssignTo',
	                           fieldLabel	:'Assign To',
	                           store		: memberDetailsStore,
	                           displayField : 'name',
	                           valueField  	: 'id',
	                           triggerAction: 'all',
	                           width		: 120,
	                           editable		: false,
	                           mode		:mode,
	                           listeners:{select:function(){
				    	   				
				    	        	  bindValue('detailAssignTo','detailAssignToId');
				    	          }
				    	   }
				    	   } ,
				    	   {xtype:'hidden',id:'detailAssignToId',value:'0'},
					       
				    	   {
				    		   xtype:'compositefield',
				    		   width:550,
				    		   items:[
				    		           {xtype:'datefield',fieldLabel:'Actual Start Date',format   : 'Y-m-d',id:'detialActualStartDT',width:120},
				    		           {xtype:'displayfield',html:'Actual End Date:'},
				    		           {xtype:'datefield',format   : 'Y-m-d',id:'detialActualEndDT'}
				    		         ]
				    	   },
				    	   
				    	   {
				    		   xtype:'compositefield',
				    		   items:[
				    		          {
				    		        	  xtype:'combo',
				    		        	  fieldLabel:'Status',
				    		        	  emptyText:'SELECT',
				    		        	  id:'detialTaskStatus',
				    		        	  store		: statusDetailStore,
				                          displayField : 'name',
				                          valueField  	: 'id',
				                          triggerAction: 'all',
				                          width		: 120,
				                          editable		: false,
				                          listeners:{select : function(){
						    	        	  bindValue('detialTaskStatus','detialTaskStatusId');
						    	          }
						    	   }
				    		        },
				    		        {xtype:'hidden',id:'detialTaskStatusId',value:'0'}
				    		        ,
				    		          {xtype:'displayfield',html:'Resolution:',width:85},
				    		          {
				    		        	  xtype:'combo',
				    		        	  emptyText:'SELECT',
				    		        	  id:'detialTaskResolution',
				    		        	  store		: resolutionDetailStore,
				                          displayField : 'name',
				                          valueField  	: 'id',
				                          triggerAction: 'all',
				                          width		: 100,
				                          editable		: false,
				                          listeners:{select : function(){
						    	        	  bindValue('detialTaskResolution','detialTaskResolutionId');
						    	          }
						    	   }
				    		        	},
				    		        	{xtype:'hidden',id:'detialTaskResolutionId',value:'0'}
				    		          ]
				    	   },
				    	  
				       ],
				       bbar:{
								xtype:'toolbar',
								buttonAlign: 'right',
								items:[
								       {
								    	   xtype:'button',
								    	   text:'Save',
								    	   id:'saveid',
								    	   handler:function(){
								    	   taskActions(projectTaskForm,'projectTask/saveTask','Task is Created Succefully',true);
								    	  
								       }
								},'-',
								
							{
						    	   xtype:'button',
						    	   text:'Clear',
						    	   id:'cancelid',
						    	   handler:function(){
									projectTaskForm.getForm().findField('id').value=undefined;
									projectTaskForm.getForm().reset();
								}
							}
								]
 	   }
    
		};
		
		
		
		
		var projectTaskForm=new Ext.form.FormPanel({
			
			id:'projectTaskForm',
			autoWidth:true,
			frame:true,
			items:[
			       {
			    	   xtype:'fieldset',title:'Create Task Details',width:750,items:[taskDescription]}
			       ,
			      
			    	{ xtype: 'box',
			    		autoEl: {
			    		tag: 'div',
			    		//cls: 'x-btn',
			    		html: '<form action="testdocument/processDoc" method="GET">' +
			    		'<input type="submit" value="Run Report" ' +
			    		'style="color:#333; font:normal 11px arial,tahoma,verdana,helvetica;" />'
			    		}
			    		}
			       ]
			    	  
		});
		

		return projectTaskForm;
		
	};
	
	function createProjectTaskUpdate(){
		var projectdetailStore=CRM.commons.createComboStore('projectdetailStore','projectTask/deatilsDropDownList','projects');
		var memberDetailsStore=CRM.commons.createComboStore('memberDetailsStore','projectTask/deatilsDropDownList');
		var priorityDetailStore=CRM.commons.createComboStore('priorityDetailStore','projectTask/deatilsDropDownList','priority');
		var statusDetailStore=CRM.commons.createComboStore('priorityDetailStore','projectTask/deatilsDropDownList','status');
		var resolutionDetailStore=CRM.commons.createComboStore('priorityDetailStore','projectTask/deatilsDropDownList','resolution');
		var unitsDetailStore=CRM.commons.createComboStore('priorityDetailStore','projectTask/deatilsDropDownList','units');
		
	
			var taskDescriptionUpdate={
					xtype:'panel',
					id:'taskDescriptionUpdate',
					layout:'form',
					
					items:[
					      
					      {xtype:'hidden',id:'id'}
					       ,
					       {   xtype    	: 'combo',
	                           id       	: 'projectTaskName',
	                           fieldLabel	:'Projects',
	                           store		: projectdetailStore,
	                           displayField : 'name',
	                           valueField  	: 'id',
	                           triggerAction: 'all',
	                           width		: 160,
	                           editable		: false,
	                           listeners : {select : function(combo,record,index){
					    	   bindValue('projectTaskName','projectTaskId');
					    	   memberDetailsStore.reload({
						       			params:{
						       			operation:'members',
						       			projectId:record.get('id')
						       			
						       		}
						       		});
					       }}
	      				   }
					       ,
					       {xtype:'hidden',id:'projectTaskId',value:'0'}
					       ,
	      				    { xtype:'textfield',fieldLabel:'TaskName',width:350,id:'taskName'}
					       ,
					       	{xtype:'textarea',fieldLabel:'Task Details',height:70,width:350,id:'taskDetail'}
					       ,
					       {
					    	   xtype:'compositefield',
					    	   items:[
					    	          {
					    	        	  xtype    	: 'combo',
				                           id       	: 'priorityTask',
				                           fieldLabel	:'Priority',
				                           store		: priorityDetailStore,
				                           displayField : 'name',
				                           valueField  	: 'id',
				                           triggerAction: 'all',
				                           width		: 160,
				                           editable		: false,
				                           listeners:{
					    	        	  select:function(){
					    	        	  bindValue('priorityTask','priorityTaskId');
					    	          }
					    	          }
					    	          }
					    	          ,
					    	          {xtype:'hidden',id:'priorityTaskId',value:'0'}
					    	          ,
					    	          {
					    	        	  xtype:'checkbox',
					    	        	  boxLabel:'MileStone',
					    	        	  id:'mileStone'
					    	          }
					    	          ]
					       },
					      /* {
					    	   	xtype	  : 'textfield',
								inputType : 'file',
								id		  : 'file',
								fieldLabel: 'Upload File'
					       },*/
					       {
					    	   xtype:'label',
					    	  
					    	   html:'<span style="font-size:14px;color:blue">Estimate Time</span><hr/>'
					    	   
					       },
					       
					       { xtype:'compositefield',
					    	   items:[
					    	          {
					    	        	  xtype:'textfield',
					    	        	  fieldLabel:'Duration',
					    	        	  id:'estmDuration',
					    	        	  width: 40
					    	          },
					    	          {
					    	        	xtype:'combo',
					    	        	id:'durationUnit',
					    	        	emptyText	 : 'SELECT',
					    	        	store		: unitsDetailStore,
				                        displayField : 'name',
				                        valueField  	: 'id',
				                        triggerAction: 'all',
				                        width		: 75,
				                        editable		: false
					    	          }
					    	          ]
					    	   },
					    	   {
					    		   xtype:'compositefield',
					    		   width:580,
					    		   items:[
					    		           {
					    		        	   xtype:'datefield',
					    		        	   fieldLabel:'Start Date',
					    		        	   format   : 'Y-m-d',
					    		        	   id:'estmStarDate',
					    		        	   width: 120,
					    		        	   listeners:{
								    	        	  blur:function(sdt){
								    	        	  var dunit=projectTaskFormUpdate.getForm().findField('durationUnit').getValue();
								    	        	  var dvalue=projectTaskFormUpdate.getForm().findField('estmDuration').getValue();
								    	        	  var nextdt=new Date(this.value);
								    	        	  if(dunit!=undefined && dvalue!=undefined)
								    	        	  {
								    	        		  
								    	        		  var num=new Number(dvalue);
								    	        		 
								    	        		  if(dunit==0)nextdt=nextdt.add(Date.HOUR,num);
								    	        		  if(dunit==1)nextdt=nextdt.add(Date.DAY,num); 
								    	        		  if(dunit==2)nextdt=nextdt.add(Date.MONTH,num);
								    	        		 
								    	        		  projectTaskFormUpdate.getForm().findField('estmEndDate').setValue(nextdt);
								    	        		
								    	        	  }
								    	          }
								    	          }
					    		        	},
					    		           {xtype:'displayfield',html:'End Date:',width: 85},
					    		           {xtype:'datefield',format   : 'Y-m-d',id:'estmEndDate',readOnly:true}
					    		           
					    		           
					    		          ]
					    	   }
					       ,
					       {
					    	   xtype:'label',
					    	  
					    	   html:'<span style="font-size:14px;color:blue">Actual Time</span><hr/>'
					    	   
					       },
					       {
				    		   xtype    	: 'combo',
	                           id       	: 'assignTo',
	                           fieldLabel	:'Assign To',
	                           store		: memberDetailsStore,
	                           displayField : 'name',
	                           valueField  	: 'id',
	                           triggerAction: 'all',
	                           width		: 120,
	                           editable		: false,
	                           mode		:'local',
	                           listeners:{
				    	        	  select:function(){ 
				    	        	  bindValue('assignTo','assignToId');
				    	        	  
				    	          }
				    	   }
				    	   },
				       {xtype:'hidden',id:'assignToId',value:'0'} ,
					       
					    	   {
					    		   xtype:'compositefield',
					    		   width:550,
					    		   items:[
					    		           {xtype:'datefield',fieldLabel:'Actual Start Date',format   : 'Y-m-d',id:'actualStartDT',width: 120},
					    		           {xtype:'displayfield',html:'Actual End Date:'},
					    		           {xtype:'datefield',format   : 'Y-m-d',id:'actualEndDT'}
					    		         ]
					    	   },
					    	   
					    	   {
					    		   xtype:'compositefield',
					    		   items:[
					    		          {
					    		        	  xtype:'combo',
					    		        	  fieldLabel:'Status',
					    		        	  emptyText:'SELECT',
					    		        	  id:'taskStatus',
					    		        	  store		: statusDetailStore,
					                          displayField : 'name',
					                          valueField  	: 'id',
					                          triggerAction: 'all',
					                          width		: 120,
					                          editable		: false,
					                          listeners:{
							    	        	  select:function(){
							    	        	  bindValue('taskStatus','taskStatusId');
							    	          }
							    	   }
					    		        },
					    		        {xtype:'hidden',id:'taskStatusId',value:'0'}
					    		        ,
					    		          {xtype:'displayfield',html:'Resolution:',width: 87},
					    		          {
					    		        	  xtype:'combo',
					    		        	  emptyText:'SELECT',
					    		        	  id:'taskResolution',
					    		        	  store		: resolutionDetailStore,
					                          displayField : 'name',
					                          valueField  	: 'id',
					                          triggerAction: 'all',
					                          width		: 100,
					                          editable		: false,
					                          listeners:{
							    	        	  select:function(){
							    	        	  bindValue('taskResolution','taskResolutionId');
							    	          }
							    	   }
					    		        	},
					    		        	{xtype:'hidden',id:'taskResolutionId',value:'0'},
					    		        	
					    		          ]
					    	   }
					    	  
					       ]
	    
			};
			
			
			
			
			var projectTaskFormUpdate=new Ext.form.FormPanel({
				
				id:'projectTaskFormUpdate',
				autoWidth:true,
				frame:true,
				items:[
				       {
				    	   xtype:'fieldset',
				    	   title:'Create Task Details',
				    	   width:750,
				    	   items:[taskDescriptionUpdate]
				    	}
				       ]
				    	  
			});
			

			return projectTaskFormUpdate;
			
		};
	var formids=['projectName','taskName','taskDetail','priority','estmDuration','durationUnit',
	             'mileStone','taskResolution','taskStatus','assignTo','actualEndDT','actualStartDT',
	             'estmEndDate','estmStarDate','taskResolution'];
 
   function taskPupupWindow(rowdata,dupdate,dremove)
   {
	
	   var  taskFormPanel=createProjectTaskUpdate();
	  	  
	  var win = new Ext.Window({
			title		: 'Task Update',
			id			: 'taskPupupWindowid',
			width		: 800,
		
			border		: true,
			plain		: false,
			closable	: true,
			collapsible : false,
			animCollapse: false,
			draggable 	: true,
			maximizable : false,
			onEsc		: true,
			model		: true,
			items		: [
			     		   	taskFormPanel
			     		  ],
			bbar        : {
			                    xtype       : 'toolbar',
			                    buttonAlign : 'right',
			                    items       : [
			                        {
			                            xtype   : 'button',
			                            text    : 'Update',
			                            hidden	:dupdate,
			                            handler : function(){
			                        	taskActions(taskFormPanel,'projectTask/updateTask','Task is Updated',false);
			                               }
			                        },'-',
			                        {
			                            xtype   : 'button',
			                            text    : 'Remove',
			                            hidden	:dremove,
			                            handler : function(){
			                        			taskActions(taskFormPanel,'projectTask/deleteTask','Task is Deleted',false);
			                        			
			                               }
			                        },'-',
									{
								    	   xtype:'button',
								    	   text:'Cancel',
								    	   id:'cancelid',
								    	   
								    	   handler:function(){
			                        		var win=Ext.getCmp('taskPupupWindowid');
			                        		win.close();
									}
									}
			                    ]
			                }     		  
		
	});
	 
	   taskFormPanel.getForm().loadRecord(rowdata);
	 
	   if(dupdate)doFormReadOnly(taskFormPanel,formids,true);
	   	
		win.show(this);
		return win;
   }
  
  
	function taskActions(formPanel,url,msg,flag)
	{
		var pass=formPanel.getForm().findField('id').value;
		
		  if(flag==true){pass=undefined;}
		
		
		    if(formPanel.getForm().findField('id').value==pass){
			var values = formPanel.getForm().getValues();
			var encoded = Ext.encode(values);
			Ext.Ajax.request({
		        		   url		: url,
		        		   method	: 'POST',
		      	           success : function(request) {  
		  	        		         
		  	        		         var tasksSearchGrid=Ext.getCmp('tasksSearchGrid');
		  	        		         var taskHomeGrid=Ext.getCmp('taskHomeGrid');
		  	        		         var mytaskGrid=Ext.getCmp('mytaskGrid');
		  	        		         mytaskGrid.store.reload();
		  	        		         taskHomeGrid.store.reload();
		  	        		        
		  	        		         formPanel.getForm().findField('id').value=request.responseText;
		  	        		         alert(msg);
		  	        		      },
		      	   failure: function() { alert ("Failure");},
		      	   jsonData: encoded  
		      	});
		    }
		    else{
		    	alert("Record is AllReady Exist.");
		    }
	}
